package com.gator.rabbitmq.pablo_rabbitmq.boot.rabbitmq.awesome.consumer;

import com.gator.rabbitmq.pablo_rabbitmq.boot.rabbitmq.config.DelayQueueConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author PABLO
 * @Date 2022/6/6 16:03
 * @Desc
 */
@Component
@Slf4j
public class DelayedQueueConsumer {

    @RabbitListener(queues = DelayQueueConfig.DELAY_QUEUE_NAME)
    public void receive(Message message, Channel channel) {
        String msg = new String(message.getBody());
        log.info("收到延迟队列消息-->当前时间:{}-->deadQueueReceiveInfo-->{}",new Date().toString(),msg);
    }
}
